package com.example.Nurse_Notifier;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import interfaces.ChangeState;

import java.util.ArrayList;

public class WindowFragmentAdapter extends FragmentPagerAdapter {

    private final int COUNT = 3;
    private ArrayList<ChangeState> changeStates;
    private HistFragment histFragment;
    private ListFragment listFragment;
    private StatsFragment statsFragment;

    public WindowFragmentAdapter(FragmentManager fm, FragmentActivity activity,
                                 XbeeDeviceContainer xbeeDeviceContainer, HistContainer histContainer) {
        super(fm);
        changeStates = new ArrayList<ChangeState>();
        histFragment = new HistFragment(histContainer, activity);
        listFragment = new ListFragment(xbeeDeviceContainer, activity);
        statsFragment = new StatsFragment(xbeeDeviceContainer, activity);
        changeStates.add(histFragment);
        changeStates.add(listFragment);
        changeStates.add(statsFragment);
    }

    public ArrayList<ChangeState> getChangeStates() {
        return changeStates;
    }

    public HistFragment getHistFragment() {
        return histFragment;
    }

    public ListFragment getListFragment() {
        return listFragment;
    }

    public StatsFragment getStatsFragment() {
        return statsFragment;
    }

    @Override
    public Fragment getItem(int i) {
        switch (i) {
            case 0:
                return histFragment;
            case 1:
                return listFragment;
            case 2:
                return statsFragment;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return COUNT;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return "История";
            case 1:
                return "Список";
            case 2:
                return "Статистика";
            default:
                return "Blank page";
        }
    }
}
